home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 12
/
CU Amiga Magazine's Super CD-ROM 12 (1997)(EMAP Images)(GB)[!][issue 1997-07].iso
/
CUCD
/
Games
/
DestructivePoker
/
sources
/
sources.lha
/
betprefs.cpp
next >
Wrap
C/C++ Source or Header
|
1997-02-13
|
4KB
|
175 lines
/*
betprefs.cpp
V1.00 - 241196 Kimmo Teräväinen
----- ------ ----------------
Look betprefs.h
*/
#include "betprefs.h"
#ifdef _Windows
DEFINE_RESPONSE_TABLE1(TPrefsBetDialog,TDialog)
// EV_CBN_SelChange(COMBO_CHANGES,Sel_Changes);
// EV_CBN_SelChange(COMBO_JOKERS ,Sel_Jokers);
EV_BN_CLICKED(IDOK ,ButtonOK),
END_RESPONSE_TABLE;
const char *TPrefsBetDialog::Numerot[] = {
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8"
};
void TPrefsBetDialog::SetupWindow()
{
int i;
TDialog::SetupWindow();
for(i=1; i<=MAX_CHANGES ; i++)
changes.InsertString(Numerot[i],i-1);
for(i=0; i<=MAX_JOKERS ; i++)
jokers.InsertString(Numerot[i],i);
changes.SetSelIndex(game->Changes()-1);
jokers.SetSelIndex(game->Jokers());
}
#else
#include <inline++/exec.h>
#include "pokergadgets.h"
const cButton cPrefsBetGadgets::PrefsBetButtons[] = {
cButton(GADGET_OK ,30,100,52,20,"OK"),
cButton(GADGET_CANCEL,300,100,52,20,"Cancel"),
cButton(0,0,0,0,0,NULL)
};
const cStringGadget cPrefsBetGadgets::PrefsBetStringGads[] = {
cStringGadget(STRING_CHANGES,130,30,30,12,"_Changes:","1",1),
cStringGadget(STRING_JOKERS ,130,50,30,12,"_Jokers:","2",1),
// cStringGadget(0,0,0,0,0,NULL,NULL,0)
};
void TPrefsBetDialog::Execute()
{
Window *Wnd=NULL;
int BTop = parent->WScreen->WBorTop + (parent->WScreen->Font->ta_YSize + 1);
{
struct TagItem window_tags[] = {
{ WA_Title, (long unsigned)"Game Preferences" },
{ WA_DragBar , TRUE},
{ WA_DepthGadget , TRUE},
{ WA_CloseGadget, TRUE },
{ WA_Left, 100+parent->LeftEdge }, { WA_Top, 50+parent->TopEdge },
{ WA_Width, 390 }, { WA_Height, 130+BTop },
{ WA_CustomScreen, (ULONG)parent->WScreen },
{ WA_Activate, TRUE},
{ WA_IDCMP, IDCMP_VANILLAKEY |
IDCMP_MOUSEBUTTONS |
IDCMP_GADGETUP |
IDCMP_REFRESHWINDOW |
IDCMP_CLOSEWINDOW },
{ TAG_DONE, NULL}
};
Wnd=OpenWindowTagList(NULL,window_tags);
}
if(Wnd)
{
int RT,terminated=FALSE;
cPrefsBetGadgets prefsgads(Wnd,game);
while(!terminated) {
Message *msg;
WaitPort(Wnd->UserPort);
while(msg=GetMsg(Wnd->UserPort)) {
if((RT=prefsgads.IDCMP((const IntuiMessage *)msg))==IDCMP_NOT_DONE)
switch(((IntuiMessage *)msg)->Class) {
case IDCMP_CLOSEWINDOW: terminated=TRUE; break;
}
if(RT==IDCMP_TERMINATED) terminated=TRUE;
if(RT!=IDCMP_REPLYED) ReplyMsg(msg);
}
}
CloseWindow(Wnd);
}
}
int cPrefsBetGadgets::GadgetOK()
{
int c=GetGadgetString(changes)-'0';
game->SetChanges(c);
c=GetGadgetString(jokers)-'0';
game->SetJokers(c);
return IDCMP_TERMINATED;
}
int cPrefsBetGadgets::IDCMP(const IntuiMessage *msg)
{
switch(msg->Class) {
case IDCMP_REFRESHWINDOW: GT_BeginRefresh(wnd);
GT_EndRefresh(wnd, TRUE);
return IDCMP_DONE;
case IDCMP_VANILLAKEY:
switch(msg->Code) {
case 10:
case 13: return GadgetOK();
case 27: return IDCMP_TERMINATED;
case 'c':
case 'C':
case 9: ActivateGadget(changes,wnd,NULL);
return IDCMP_DONE;
case 'j':
case 'J': ActivateGadget(jokers,wnd,NULL);
return IDCMP_DONE;
}
break;
case IDCMP_GADGETUP:
Gadget *gad = (struct Gadget *)msg->IAddress;
switch(gad->GadgetID) {
case STRING_CHANGES:
{
int c=GetGadgetString(gad)-'0';
if(c<1) c=1;
if(c>MAX_CHANGES) c=MAX_CHANGES;
SetGadgetString(gad,c+'0');
break;
}
case STRING_JOKERS:
{
int c=GetGadgetString(gad)-'0';
if(c<0) c=0;
if(c>MAX_JOKERS) c=MAX_JOKERS;
SetGadgetString(gad,c+'0');
break;
}
case GADGET_OK: return GadgetOK();
case GADGET_CANCEL: return IDCMP_TERMINATED;
}
return IDCMP_DONE;
}
return IDCMP_NOT_DONE;
}
#endif